//
//  DMoreViewController.swift
//  Drop
//
//  Created by hushaohua on 2017/11/13.
//  Copyright © 2017年 init. All rights reserved.
//

import UIKit


class DMoreViewController: DMoreListViewController {

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil);
        self.title = "More";
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "统计";
    }

    override func tableRowSections() -> [[DTableRowItem]] {
        var sections:[[DTableRowItem]] = [[DTableRowItem]]();
        var section0:[DTableRowItem] = [DTableRowItem]();
        section0.append(DTableRowItem(title:"TAG", closure: { (indexPath) in
            self.gotoTags();
        }));
        section0.append(DTableRowItem(title:"时间线", closure: { (indexPath) in
            self.gotoTimeline();
        }));
        sections.append(section0);
        
        var section1:[DTableRowItem] = [DTableRowItem]();
        section1.append(DTableRowItem(title:"TAG", closure: { (indexPath) in
            self.gotoTagAnalysis();
        }));
        section1.append(DTableRowItem(title:"日期", closure: { (indexPath) in
            self.gotoDateAnalysis();
        }));
        sections.append(section1);
        
        var section2:[DTableRowItem] = [DTableRowItem]();
        section2.append(DTableRowItem(title:"TAG", closure: { (indexPath) in
            self.gotoTagAnalysis();
        }));
        section2.append(DTableRowItem(title:"日期", closure: { (indexPath) in
            self.gotoDateAnalysis();
        }));
        sections.append(section2);
        
        var section3:[DTableRowItem] = [DTableRowItem]();
        section3.append(DTableRowItem(title:"Preference", closure: { (indexPath) in
            self.gotoPreferences();
        }));
        sections.append(section3);
        
        return sections;
    }
    
    @objc func gotoTimeline() -> Void{
        let controller = DDropLineViewController();
        controller.hidesBottomBarWhenPushed = true;
        self.navigationController?.pushViewController(controller, animated: true);
    }
    
    @objc func gotoDateAnalysis() -> Void{
        let controller = DDateAnalysisViewController(style: .plain);
        controller.hidesBottomBarWhenPushed = true;
        self.navigationController?.pushViewController(controller, animated: true);
    }
    
    @objc func gotoTagAnalysis() -> Void{
        let controller = DTagsAnalysisViewController(nibName: nil, bundle: nil);
        controller.hidesBottomBarWhenPushed = true;
        self.navigationController?.pushViewController(controller, animated: true);
    }
    
    @objc func gotoTags() -> Void {
        let controller:DTagsViewController = DTagsViewController(style:.plain);
        controller.hidesBottomBarWhenPushed = true;
        self.navigationController?.pushViewController(controller, animated: true);
    }
    
    @objc func gotoPreferences() -> Void {
        let controller:DPreferenceViewController = DPreferenceViewController(nibName:nil, bundle:nil);
        controller.hidesBottomBarWhenPushed = true;
        self.navigationController?.pushViewController(controller, animated: true);
    }
    
    func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        switch section {
        case 0:
            return "存储";
        case 1:
            return "统计";
        case 2:
            return "查询";
        case 3:
            return "设置";
        default:
            return "";
        }
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}
